import { login } from "@/api/account";
import { saveToken } from "@/utils/auth";
import router from "@/router";
const state = {
  avatar:
    "https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1540294328584&di=9eb8f47f4100fd61d33d9c3b0d0beb74&imgtype=0&src=http%3A%2F%2Fimg4.duitang.com%2Fuploads%2Fitem%2F201501%2F25%2F20150125094246_xBn2x.jpeg"
};
const mutations = {};
const actions = {
  async login({ comimit }, user) {
    const username = user.username.trim();
    const { token } = await login(username, user.password);
    saveToken(token);
    router.push({ path: "/" });
  }
};

export default {
  state,
  mutations,
  actions
};
